//
//  WCTPostMess.m
//  WeChatTool
//
//  Created by TerryChe on 2016/12/5.
//  Copyright © 2016年 TerryChe. All rights reserved.
//

#import "WCTChatMsg.h"
#import "WCTConfig.h"

@implementation WCTChatMsg

+ (instancetype)WCTChatMsgByTalter:(NSString *)talter
                           Content:(NSString *)content
                            Issend:(NSInteger)issend
                           Resvred:(NSString *)resvred
                          WechatID:(NSString *)wechatID
                              Sate:(NSInteger)sate
                              Time:(NSString *)time
                          SermsgID:(NSString *)sermsgID{
    return [[self alloc] initWithTalter:talter
                                Content:content
                                 Issend:issend
                                Resvred:resvred
                               WechatID:wechatID
                                   Sate:sate
                                   Time:time
                               SermsgID:sermsgID];
}

- (instancetype)initWithTalter:(NSString *)talter
                       Content:(NSString *)content
                        Issend:(NSInteger)issend
                       Resvred:(NSString *)resvred
                      WechatID:(NSString *)wechatID
                          Sate:(NSInteger)sate
                          Time:(NSString *)time
                      SermsgID:(NSString *)sermsgID{
    if (self = [super init]) {
        self.talter = formatEmptyString(talter);
        self.content = formatEmptyString(content);
        self.issend = issend;
        self.resvred = formatEmptyString(resvred);
        self.wechatID = formatEmptyString(wechatID);
        self.sate = sate;
        self.time = formatEmptyString(time);
        self.sermsgID = formatEmptyString(sermsgID);
    }
    
    return self;
}

- (NSDictionary *)convertToDic:(BOOL)hasExpand{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:[WCTConfig sharedInstance].batchCount];
    
    [dic setObject:formatEmptyString(self.talter) forKey:str_chatmsg_talter];
    [dic setObject:formatEmptyString(self.content) forKey:str_chatmsg_content];
    [dic setObject:@(self.issend) forKey:str_chatmsg_issend];
    [dic setObject:formatEmptyString(self.resvred) forKey:str_chatmsg_resvred];
    [dic setObject:formatEmptyString(self.wechatID) forKey:str_chatmsg_wechatid];
    [dic setObject:@(self.sate) forKey:str_chatmsg_sate];
    [dic setObject:formatEmptyString(self.time) forKey:str_chatmsg_time];
    [dic setObject:formatEmptyString(self.sermsgID) forKey:str_chatmsg_sermsgid];
    
    if (hasExpand && ![self.sermsgID  isEqual: @""]) {
        [dic setObject:@(1) forKey:@"ad_expand"];
    }
    
    return dic;
}

@end
